package com.simple.security.controller;


import com.mmm.station.security.entity.Token;
import com.mmm.station.security.method.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by mmm on 2016/12/7.
 */
@RestController
public class LoginController {

    @Autowired
    private ValueOperations<Object,Object> redis;


    @RequestMapping(value = "login")
    public String login(String userName,String password) {
        if (userName != null && password != null) {
            if (Subject.getInstance().login(new Token(userName, password))) {
                return "登录成功";
            }
        }
        return "登录失败";
    }

    @RequestMapping(value = "logout")
    public String logout() {
        Subject.getInstance().logout();
        return "注销成功";
    }


}
